﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CFSystem.JXC.Model
{
    using System.ComponentModel;

    public class StockInfo
    {
        #region 进货相关信息
        /// <summary>
        /// 进货表的自动ID值
        /// </summary>
        private int _id;
        [Browsable(false)]
        public int ID
        {
            get { return _id; }
            set { _id = value; }
        }

        /// <summary>
        /// 进货批次
        /// </summary>
        private string _batchID;
        [DisplayName("进货批次")]
        public string BatchID
        {
            get { return _batchID; }
            set { _batchID = value; }
        }

        /// <summary>
        /// 供应商编号
        /// </summary>
        private string _vendorID;
        [Browsable(false)]
        public string VendorID
        {
            get { return _vendorID; }
            set { _vendorID = value; }
        }

        /// <summary>
        /// 供应商名称
        /// </summary>
        private string _vendorName;
        [DisplayName("供货商")]
        public string VendorName
        {
            get { return _vendorName; }
            set { _vendorName = value; }
        }

        /// <summary>
        /// 以下是商品的具体信息
        /// </summary>
        private ProductInfo _product;
        [Browsable(false)]
        public ProductInfo Product
        {
            get { return _product; }
            set { _product = value; }
        }

        [DisplayName("商品编号")]
        public string ProductID
        {
            get { return _product.ProductID; }
        }

        [DisplayName("商品名称")]
        public string ProductName
        {
            get { return _product.ProductName; }
        }

        [DisplayName("类别")]
        public string ProductCategory
        {
            get { return _product.CatergoryName; }
        }

        [DisplayName("规格")]
        public string ProductSpecification
        {
            get { return _product.SpecificationName; }
        }

        [DisplayName("颜色")]
        public string ProductColor
        {
            get { return _product.ColorName; }
        }

        [DisplayName("单位")]
        public string ProductUnit
        {
            get { return _product.UnitName; }
        }

        /// <summary>
        /// 进货数量
        /// </summary>
        private int _stockAmount;
        [DisplayName("进货数量")]
        public int StockAmount
        {
            get { return _stockAmount; }
            set { _stockAmount = value; }
        }

        [DisplayName("进货单价")]
        public string StockPrice
        {
            get { return _product.PurchasePrice; }
        }

        [DisplayName("金额")]
        public double TotalPrice
        {
            get 
            {
                try
                {
                    if (StockAmount > 0 && Convert.ToDouble(StockPrice) > 0)
                    {
                        return StockAmount * Convert.ToDouble(StockPrice);
                    }
                    else
                    {
                        return 0;
                    }
                }
                catch (Exception)
                {
                    return 0;
                }
            }
        }

        /// <summary>
        /// 进货日期
        /// </summary>
        private string _stockDate;
        [DisplayName("进货日期")]
        public string StockDate
        {
            get { return _stockDate; }
            set { _stockDate = value; }
        }

        [DisplayName("品牌")]
        public string ProductBrand
        {
            get { return _product.BrandName; }
        }

        [DisplayName("备注")]
        public string Note
        {
            get { return _product.Note; }
        }
        #endregion

        #region Constructors
        public StockInfo()
        {
            _batchID = string.Empty;
            _vendorID = string.Empty;
            _vendorName = string.Empty;
            _stockDate = string.Empty;
            _product = new ProductInfo();
            _stockAmount = 0;
        }

        public StockInfo(int recordID)
        {
            _id = recordID;
        }
        #endregion
    }
}
